package com.headfirst.dmp.utils

/**
  * 地域分析报表的工具类
  */
object AreaAnalyzeUtils {

  /**
    * 筛选原始请求、有效请求、广告请求
    *
    * @param requestmode
    * @param processnode
    * @return List（原始请求、有效请求、广告请求）
    */
  def caculateReq(requestmode: Int, processnode: Int): List[Double] = {
    if (requestmode == 1 && processnode == 1) {
      List(1, 0, 0)
    } else if (requestmode == 1 && processnode == 2) {
      List(0, 1, 0)
    } else if (requestmode == 1 && processnode == 3) {
      List(0, 0, 1)
    } else {
      List(0, 0, 0)
    }
  }


  /**
    * 筛选参与竞价的次数，参与竞价的次数
    *
    * @param adplatformproviderid
    * @param iseffective
    * @param isBilling
    * @param isBid
    * @param ADOrderid
    * @param isWin
    * @return List（参与竞价的次数,参与竞价的次数）
    */
  def caculateBid(adplatformproviderid: Int, iseffective: Int, isBilling: Int, isBid: Int, ADOrderid: Int, isWin: Int): List[Double] = {
    if (adplatformproviderid >= 100000 && iseffective == 1 && isBilling == 1 && isBid == 1 && ADOrderid != 0) {
      List(1, 0)
    } else if (adplatformproviderid >= 100000 && iseffective == 1 && isBilling == 1 && isWin == 1) {
      List(0, 1)
    } else {
      List(0, 0)
    }
  }


  /**
    * 筛选展示数,点击数
    *
    * @param requestMode
    * @param iseffective
    * @return List(展示数，点击数)
    */
  def caculateShowAndClick(requestMode: Int, iseffective: Int): List[Double] = {
    if (requestMode == 2 && iseffective == 1) {
      List(1, 0)
    } else if (requestMode == 3 && iseffective == 1) {
      List(0, 1)
    } else {
      List(0, 0)
    }
  }


  /**
    * 筛选 广告消费 ，广告成本
    * @param adplatformproviderid
    * @param iseffective
    * @param isBilling
    * @param isWin
    * @param ADOrderid
    * @param adcreativeid
    * @param WinPrice
    * @param adPayment
    * @return  List(广告消费,广告成本)
    */
  def caculateCost(adplatformproviderid: Int, iseffective: Int, isBilling: Int, isWin:Int, ADOrderid: Int, adcreativeid: Int,WinPrice:Double,adPayment:Double): List[Double] = {
    if(adplatformproviderid >=100000 && iseffective==1 && isBilling==1 && isWin==1 && ADOrderid>=200000 && adcreativeid>=200000){
      List(WinPrice/1000,adPayment/1000)
    }else{
      List(0,0)
    }
  }

}
